package cn.tyoui.UI;

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JLabel;

public class OpenFile extends javax.swing.JFrame {

	private javax.swing.JFileChooser choose;
	static String path="";
	private static final long serialVersionUID = 1L;
	public OpenFile() {
		setVisible(false);
	}

	public String startFile() {
		choose = new javax.swing.JFileChooser();
		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
						.addComponent(choose, javax.swing.GroupLayout.PREFERRED_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(0, 20, Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
						.addComponent(choose, javax.swing.GroupLayout.PREFERRED_SIZE,
								javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(0, 20, Short.MAX_VALUE)));

		pack();
		choose.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
		choose.showDialog(new JLabel(),"文件");
		File file=choose.getSelectedFile();
		String string=file.getAbsolutePath().toString();
		path=string;
		return string;
	}
	public void close(){
		setVisible(false);
	}
}
